package com.aaa.stock.service.examine.impl;

import com.aaa.entity.Purchase;
import com.aaa.stock.dao.examine.ExamineDao;
import com.aaa.stock.service.examine.ExamineService;
import com.aaa.stock.vo.ExamineVo;
import com.aaa.vo.Result;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

@Service
public class ExamineServiceImpl implements ExamineService {
    @Autowired
    private ExamineDao examineDao;

    @Override
    public Result<IPage<Purchase>> getAll(Integer currentPage, Integer pageSize, ExamineVo examineVo) {
        IPage<Purchase> page=new Page<>(currentPage,pageSize);
        QueryWrapper<Purchase> wrapper=new QueryWrapper<>();
        if(StringUtils.hasText(examineVo.getProviderId())){
            wrapper.like("provider_id",examineVo.getProviderId());
        }
        if(StringUtils.hasText(examineVo.getUserName())){
            wrapper.eq("apply_user_name",examineVo.getUserName());
        }
        wrapper.eq("status",2);
        IPage<Purchase> page1 = examineDao.selectPage(page, wrapper);
        return new Result<IPage<Purchase>>(2000,"查询厂家成功",page1);
    }
}
